package com.meiborte.controller;

import com.meiborte.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.meiborte.pojo.Result;
import com.meiborte.pojo.User;

@RestController
public class LoginContorller {

    @Autowired
    private UserService userService;

    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public Result login(@RequestBody User user) {
        User u = userService.login(user);
        return u == null ? Result.error("用户名或者密码有误！") : Result.success(u);
    }
}
